﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using HZ.MBSM.DBUtility;
public partial class Hospital_hospitalReceiptid_ : System.Web.UI.Page
{
    public string HCPSRowNum, HCPHosId;
    protected void Page_Load(object sender, EventArgs e)
    {
        //HCPSProjectID = SysFun.ToInt(Request.QueryString["ProjectId"].ToString());   2007/08/22 马
        HCPSRowNum = SysFun.IsSQL(SysFun.ToTrim(Request.QueryString["rownum"]));
        if (HCPSRowNum == "")
        {
            HCPSRowNum = "0";
        }
        HCPHosId = SysFun.IsSQL(SysFun.ToTrim(Request.QueryString["Hosid"]));
        if (HCPHosId == "")
        {
            HCPHosId = "0";
        }

        showGridView();

    }
    /// <summary>
    /// 数据绑定
    /// </summary>
    public void showGridView()
    {
        string strConditions;
        strConditions = fctConditions();
        Db db = new Db();
        DbPage dbPage = new DbPage(db);
        dbPage.Table = "BuyGoodsView_200708";//要查询的表明
        dbPage.Key = "Receiptid";                                               //表的主键    
        dbPage.Where = strConditions;                                           //查询条件    
        dbPage.SelectField = "distinct Receiptid,AccountId_PS,CompanyName_PS,UserCode_PS";//要显示的字段
        dbPage.PageIndex = SysFun.ToInt(Request["CurrentlyPageIndex"]);          //要显示第几页   
        dbPage.PageSize = 30;                                                    //没有显示记录条数   
        dbPage.OrderBy = "CompanyName_PS";                  //排序字段
        System.Data.IDataReader dr = dbPage.ExecuteReader();
        DlAttorney.DataSource = dr;
        DlAttorney.DataBind();
        dr.Close();
        dr.Dispose();
        
        this.DbPageFlip1.DbPage = dbPage;//将数据传给控键
        dbPage.Db.Close();
        db.Close();
    }
    /// <summary>
    /// 生成查询条件
    /// </summary>
    /// <returns></returns>
    public string fctConditions()
    { 
        HZ.MBSM.Model.Account _Account = (HZ.MBSM.Model.Account)Session["Account"];
        string strtemp = "", CompanyName = "", UserCode;
        UserCode = txtUserCode.Text;
        CompanyName = txtAttorneyName.Text.ToString();
        //strtemp = " ProjectId=" + HCPSProjectID.ToString() + " And SupplyStatus=1 And";   2007/08/22 马
        strtemp += " DealStatus='2' and Receiptid is not null and Accountid_PS='" + Request.QueryString["Accountid_PS"].ToString() + "' and ispayment is null and accountid_yy=" + _Account.AccountId + " and";
        if (Request.QueryString["Page"] == "YYJSD")
        {
          

            // strtemp += " accountid_ps in (select distinct accountid_ps from HospitalPurchase where projectid=" + HCPSProjectID + " and accountid_yy=" + _Account.AccountId + ") and";
            //2007/08/22 马
            strtemp += " accountid_ps in (select distinct accountid_ps from HospitalPurchase where accountid_yy=" + _Account.AccountId + ") and";

        }
       
        if (UserCode != "")
        {
            strtemp = strtemp + " UserCode_PS like '%" + UserCode + "%' and";
        }
        if (CompanyName != "")
        {
            strtemp = strtemp + " CompanyName_PS like '%" + CompanyName + "%' and";
        }
        if (strtemp != "")
        {
            strtemp = "  " + strtemp.Substring(0, strtemp.Length - 3);
        }
        return strtemp;

    }
}
